#include "Rp2Renderer.h"

using namespace Rp2;

GLenum Renderer::ms_aeZBufferCompare[ZBufferState::CF_QUANTITY] =
{
    GL_NEVER,
    GL_LESS,
    GL_EQUAL,
    GL_LEQUAL,
    GL_GREATER,
    GL_NOTEQUAL,
    GL_GEQUAL,
    GL_ALWAYS
};

//---------------------------------------------------------------------------------------------------
void Renderer::SetZBufferState(ZBufferState* pkZBufferState)
{
    m_aspkState[GlobalState::ZBUFFER] = pkZBufferState;

	if (pkZBufferState->Enabled)
	{
		glEnable(GL_DEPTH_TEST);
		glDepthFunc(ms_aeZBufferCompare[pkZBufferState->Compare]);
	}
	else
	{
		glDisable(GL_DEPTH_TEST);
		glDepthFunc(GL_ALWAYS);
	}

	if(pkZBufferState->Writable)
	{
		glDepthMask(GL_TRUE);
	}
	else
	{
		glDepthMask(GL_FALSE);
	}
}
//---------------------------------------------------------------------------------------------------